package com.zz.ecommerce.common;

import java.util.HashMap;
import java.util.Map;

/**
 * ����������ѯ��
 */
public class Criteria {

    /**
     * ���������ѯֵ
     */
    private Map<String, Object> condition;

    /**
     * �Ƿ�����
     */
    protected boolean distinct;

    /**
     * �����ֶ�
     */
    protected String orderByClause;

    /**
     * ÿҳ��С����mysql�е�length
     */
    private Integer limit;

    /**
     * ��ʼ��������mysql�е�offset
     */
    private Integer start;

    protected Criteria(Criteria example) {
        this.orderByClause = example.orderByClause;
        this.condition = example.condition;
        this.distinct = example.distinct;
        this.limit = example.limit;
        this.start = example.start;
    }

    public Criteria() {
        this.condition = new HashMap<String, Object>();
    }

    public void clear() {
        this.condition.clear();
        this.orderByClause = null;
        this.distinct = false;
        this.limit = null;
        this.start = null;
    }

    /**
     * @param condition ��ѯ����������
     * @param value     ��ѯ��ֵ
     */
    public Criteria put(String condition, Object value) {
        this.condition.put(condition, value);
        return (Criteria) this;
    }

    /**
     * @param orderByClause �����ֶ�
     */
    public void setOrderByClause(String orderByClause) {
        this.orderByClause = orderByClause;
    }

    /**
     * @param distinct �Ƿ�����
     */
    public void setDistinct(boolean distinct) {
        this.distinct = distinct;
    }

    public void setCondition(Map<String, Object> condition) {
        this.condition = condition;
    }

    public Map<String, Object> getCondition() {
        return condition;
    }

    /**
     * @param limit ÿҳ��С����mysql�е�length
     */
    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    /**
     * @param start ��ʼ��������mysql�е�offset
     */
    public void setStart(Integer start) {
        this.start = start;
    }

    public boolean isDistinct() {
        return this.distinct;
    }

    public String getOrderByClause() {
        return this.orderByClause;
    }

    public Integer getLimit() {
        return this.limit;
    }

    public Integer getStart() {
        return this.start;
    }
}
